<?php

namespace App\Http\Middleware;

use Closure;
use App\Models\User;

class NeedUserLogin {
    public function handle($request, Closure $next) {
        $uid = session('app_uid');
        if($uid) {
            $request->app_user = User::findOrFail($uid);
            return $next($request);
        }
        return redirect('/login?next=/' . request()->path());
    }
}
